<template>
  <div>
    <v-chart ref="chart" class="chart" :option="option" :autoresize="true" />
    <v-chart class="chart" :option="mapOption" :autoresize="true" />
    <button @click="setData">更新数据</button>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import chinaData from '@/data/china.json'
echarts.registerMap('china', chinaData) // 注册地图
import VChart from 'vue-echarts' // 依赖echarts
export default {
  components: {
    VChart
  },
  data() {
    return {
      option: { // 配置项
        title: {
          text: 'ECharts 入门示例'
        },
        tooltip: {},
        xAxis: {
          data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
        },
        yAxis: {},
        series: [{
          name: '销量',
          type: 'bar',
          data: [5, 20, 36, 10, 10, 20]
        }]
      },
      mapOption: {
        geo: {
          map: 'china'
        }
      }
    }
  },
  mounted() {

    // echarts.registerMap('china', chinaData) // 注册地图
  },
  methods: {
    setData() {
      this.option.series[0].data = [15, 10, 16, 30, 40, 10] // 不需要调用实例的setOption方法
    }
  }
}
</script>

<style scoped>
.chart{
    width: 30vw;
    height: 500px;
}
</style>
